<?php 
if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Deal extends CI_Model{
    
    function __construct()
    {
        parent::__construct();
        $this->load->database();
    }
    function get_hot_deals()
    {
        $query = $this->db->query("
            SELECT p.product_id, p.viewed, p.image, p.price, p.date_added, pdes.name, pdes.duration, pdis.price AS disprice, pdis.date_start, pdis.date_end 
            FROM product p LEFT JOIN product_description pdes ON p.product_id = pdes.product_id LEFT JOIN product_discount pdis ON p.product_id = pdis.product_id 
            ORDER BY p.viewed, p.product_id DESC ");
        
        return $query->result();
    }
}
